package org.mifos.boss.service.helper;

import org.exolab.castor.tools.MappingTool;
import org.exolab.castor.xml.XMLContext;
import org.mifos.boss.domainmodel.CSIndividualSavingsAccount;
import org.mifos.boss.domainmodel.CSLoanAccount;
import org.mifos.boss.domainmodel.CSSavingsAccount;
import org.mifos.boss.domainmodel.ClientCollectionData;
import org.mifos.boss.domainmodel.CollectionSheet;

import java.io.*;

/**
 * 
 * generate a Castor mapping file ready for editing
 */

public class CastorMapper {

	/**
	 * 
	 * generate a Castor mapping file ready for editing
	 */

	public CastorMapper()
	{}
	
	public static void main(String[] args)

	{
		
		XMLContext context = new XMLContext(); 
		MappingTool tool = context.createMappingTool(); 
		
		
//		MappingTool tool = new MappingTool();
//		mapToolsetInternalContext(new org.castor.xml.BackwardCompatibilityContext());
		try{
			
		
		
		tool.addClass(CollectionSheet.class);
		tool.addClass(ClientCollectionData.class);
		tool.addClass(CSIndividualSavingsAccount.class);
		tool.addClass(CSLoanAccount.class);
		tool.addClass(CSSavingsAccount.class);
		
		OutputStream file = new FileOutputStream("gen_mapping.xml");
//		System.out.println(file.);
		Writer writer = new OutputStreamWriter(file);

		tool.write(writer);
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}


}
